<!-- <template>
	<view class="item">
		<u-form class="form_info" :model="form" ref="uForm"
			:label-style="{'font-size':'24rpx','color':'rgba(56, 56, 56, 1)','height':'30rpx'}">
			<view class="uform">
				<u-form-item label="法人编号" label-width='150' label-position="left" prop="legal_number">
					<u-input placeholder="请输入相应证件号" v-model="form.legal_number" type="text" height="40"
						placeholder-style="color:rgba(166, 166, 166, 1);font-size:20rpx;line-height:100%" />
				</u-form-item>
			</view>
		</u-form>
		<view class="photo_info">
			<u-icon name="info-circle-fill" class="hinticon" size="35" :label="hinttext"
				label-color="rgba(56, 56, 56, 1)">
			</u-icon>
			<view class="imag">
				<u-upload ref="uUpload" max-count="1" width="390" height="220" custom-btn :auto-upload="false"
					@on-choose-complete="afterRead">
					<view slot="addBtn" class="slot-btn slot-btn1">
					</view>
				</u-upload>
				<view class="hinttext">请上传法人证明原件</view>
			</view>
		</view>
		<button class="submit" :ripple="true" :hair-line="false" @click="submit()">开始认证</button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				hinttext: '请拍摄或上传证件照原件，确保证件真实性！',
				form: {
					legal_number: '',
					imageurl: ''
				},
				rules: { //验证规则
					legal_number: [{
							required: true,
							message: '请填写法人编号',
							trigger: ['change', 'blur']
						},
						{
							pattern: /^[A-Za-z0-9]+$/,
							message: '法人编号有误',
							trigger: ['blur']
						}
					],
				}
			}
		},
		methods: {
			async afterRead(event) {
				this.$upLoadfile({
					url: '/upload/imgUpload',
					filePath: event[0].url,
					name: 'file'
				}).then(res => {
					console.log(res.data)
					if (res.statusCode === 200) {
						let imgurl = JSON.parse(res.data)
						this.form.imageurl = imgurl.data; //idFrontImg
					}
				})
			},
			submit() {
				let postdata = {
					'registrationNum': this.form.legal_number,
					'businessLicenseImgPath': this.form.imageurl,
				}
				this.$refs.uForm.validate(valid => {
					if (valid) {
						if (this.form.image != '') {
							setTimeout(() => {
								this.$myRequest({
									url: '/legal/legalCertification',
									method: 'POST',
									data: postdata
								}).then((res) => {
									console.log(res);
									if (res.statusCode == 200) {
										getApp().globalData.userinfo.user_status == 1;
										this.goto('../operatesuccess/operatesuccess')
									}
								});
							}, 2000);
						} else {
							uni.showToast({
								title: '请上传法人证明',
								icon: 'none'
							})
							return false;
						}

					} else {
						console.log('认证失败');
						return 0;
					}
				});

			},
			//页面跳转
			goto(url) {
				let turl = url + '?delta=3&' + 'successtext=认证成功';
				console.log(turl);
				uni.navigateTo({
					url: turl,
					animationType: 'slide-in-right',
					animationDuration: 1000

				})
			},
			setvalue(i) {
				this.sec = i;
			},
		},
		onReady() { //生命周期
			this.$refs.uForm.setRules(this.rules);
		}
	}
</script>

<style>
	@import url("legal_person.css");
</style>
 -->